

from scipy import stats
import numpy as np

(p, num) = (0.3, 6)
binomDist = stats.binom(num, p)
binomDist.pmf(np.arange(7))
#(1)恰有4个顾客购买，即0.09535
#(2)购买的顾客不超过一半即有0到3个顾客购买，即0.117649+
#0.302526+0.324135+0.18522=0.92953
#(3)至少有一个顾客购买即1-除了没有人买的概率，0.88231

